﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WMS.Entity;
using WMS.BLL;

namespace WMS.App
{
    public partial class frmMain : Form
    {
        #region Private
        private frmInventoryGoods fInventoryGoods = null;
        private frmUnit fUnit = null;
        private frmCategory fCategory = null;
        private frmGoodsInfo fGoodsInfo = null;
        #endregion

        #region Public
        public UserInfoEntity userInfo;
        public EventHandler CloseWindwsEvent = null;
        public ProcessingEventHandler Processing = null;
        #endregion

        public frmMain()
        {
            InitializeComponent();

            HideComponnet();
        }

        #region Private Methods
        void HideComponnet()
        {
            this.MenuSystemSetting.Visible = false;
            this.MenuWindows.Visible = false;
        }
        #endregion

        #region Public Methods
        public void InitData()
        {
            fInventoryGoods = new frmInventoryGoods();
            fInventoryGoods.MdiParent = this;
            fInventoryGoods.StartPosition = FormStartPosition.CenterParent;
            Processing(10);

            fUnit = new frmUnit();
            fUnit.MdiParent = this;
            fUnit.StartPosition = FormStartPosition.CenterParent;
            Processing(20);

            fCategory = new frmCategory();
            fCategory.MdiParent = this;
            fCategory.StartPosition = FormStartPosition.CenterParent;
            Processing(30);

            fGoodsInfo = new frmGoodsInfo();
            fGoodsInfo.MdiParent = this;
            fGoodsInfo.StartPosition = FormStartPosition.CenterParent;
            Processing(40);

            userInfo = new UserInfoEntity();
            Processing(100);
        }
        #endregion

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        #region 窗体排序
        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }
        #endregion

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (CloseWindwsEvent != null)
                CloseWindwsEvent(this, null);
        }

        private void TSMenuItemOutGoods_Click(object sender, EventArgs e)
        {
            fInventoryGoods.AddInGoodsLog = false;
            fInventoryGoods.InitData();
            fInventoryGoods.Show();
            fInventoryGoods.Focus();
        }

        private void tstripMenuItemInGoods_Click(object sender, EventArgs e)
        {
            fInventoryGoods.AddInGoodsLog = true;
            fInventoryGoods.InitData();
            fInventoryGoods.Show();
            fInventoryGoods.Focus();
        }

        private void TSMenuItemUnit_Click(object sender, EventArgs e)
        {
            fUnit.Show();
            fUnit.Focus();
        }

        private void TSMenuItemProductCategory_Click(object sender, EventArgs e)
        {
            fCategory.Show();
            fCategory.Focus();
        }

        private void TSMenuItemAddGood_Click(object sender, EventArgs e)
        {
            //fGoodsInfo.FillDataToForm(2);
            fGoodsInfo.ClearFormValue();
            fGoodsInfo.Show();
            fGoodsInfo.Focus();
        }

       
    }
}
